package com.dot.dominion.boardview;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.GridView;

import com.dot.dominion.Constants;
import com.dot.dominion.Game;
import com.dot.dominion.R;
import com.dot.dominion.domain.Card;

public class BoardView extends Activity {
	private Integer[] images;
	private List<Card> cards;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView( R.layout.boardview );
        
        setupImages();
        cards = ((Game) getApplication()).getBoardList();
        
        
        GridView board = (GridView) findViewById( R.id.boardview_grid );
        board.setAdapter(new BoardAdapter(this, images));
        board.setOnItemClickListener(new BoardListener(this, cards));
    }
	
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		Log.d("DEBUGTAG", "requestCode--"+requestCode);
		Log.d("DEBUGTAG", "resultCode--"+resultCode);
	}
	
	private void setupImages() {
		images = new Integer[Constants.BOARD_SIZE];
		Game _game = (Game) getApplication();
		
		List<Card> list = _game.getBoardList();
		
		for(int i = 0; i < list.size(); i++)
			images[i] = list.get(i).getBoardId();
	
		_game = null;
	}
}
